package com.superbytecode.common.exception;

import com.superbytecode.common.response.IResponseCode;
import com.superbytecode.common.enums.ResponseCodeEnum;
import lombok.Getter;

/**
 * All rights Reserved, Designed By www.super-bytecode.com
 *
 * @ProjectName: superbytecode-beacon
 * @Package: com.superbytecode.common.exceptions
 * @ClassName: BusinessException
 * @Description: []
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2023/11/21 15:40
 * @Version: V1.0
 * @Copyright: 2023 www.super-bytecode.com Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@Getter
public class BusinessException extends RuntimeException {
    private final String errcode;
    private final String errmesg;

    public BusinessException(IResponseCode responseCode) {
        super(responseCode.getCode() + responseCode.getMessage());
        this.errcode = responseCode.getCode();
        this.errmesg = responseCode.getMessage();
    }

    public BusinessException(String code, String message) {
        super(code + message);
        this.errcode = code;
        this.errmesg = message;
    }

    public BusinessException(String message) {
        super(message);
        this.errcode = ResponseCodeEnum.FAILURE.getCode();
        this.errmesg = message;
    }

}